package com.engineering.elink.hessian.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.engineering.elink.domain.Video;
import com.engineering.elink.hessian.VideoHessianService;
import com.engineering.elink.videodao.VideoMapper;

@Service("videoHessianService")
public class VideoHessianServiceImpl implements VideoHessianService{
	private Logger logger=Logger.getLogger(VideoHessianServiceImpl.class);

	@Autowired
	private VideoMapper videoMapper;
	
	@Override
	public boolean updateVideo(Video video) {
		Video oldVideo=this.videoMapper.selectByOssId(video.getOssId());
		if(oldVideo==null){
			logger.info("通过OSSID无法找到视频信息！");
			return false;
		}
		
		try {
			//PropertyUtils.copyProperties(oldVideo, video);
			
			oldVideo.setTrancodeStatus(video.getTrancodeStatus());
			oldVideo.setVideoTime(video.getVideoTime());
			oldVideo.setVideoSize(video.getVideoSize());
			
			this.videoMapper.updateByPrimaryKeySelective(oldVideo);
			
			return true;
			
		} catch (Exception e) {
			logger.info("hessian接口更新视频在转换对象时产生错误！");
			e.printStackTrace();
		} 
		
		return false;
	}
	
}
